package org.l.qiao.dao;

import org.l.qiao.AbstractCollectionDAO;
import org.l.qiao.Template;
import org.l.qiao.search.TemplateSearch;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class TemplateDAOAbstract extends AbstractCollectionDAO {

    public static final String COLLECTION = "c_template";

    public TemplateDAOAbstract() {
        super(COLLECTION);
    }

    public Template removeTemplate(String id) {
        TemplateSearch ts = new TemplateSearch();
        ts.idEQ(id);
        Map<String, Object> m = findAndRemove(ts);
        if (m == null) {
            return new Template();
        } else {
            return new Template(m);
        }
    }
}
